[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct SHFILEOPSTRUCT
{
public IntPtr hwnd;
public FO_Func wFunc;
[MarshalAs(UnmanagedType.LPWStr)]
public string pFrom;
[MarshalAs(UnmanagedType.LPWStr)]
public string pTo;
public ushort fFlags;
public bool fAnyOperationsAborted;
public IntPtr hNameMappings;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpszProgressTitle;
}
Structure SHFILEOPSTRUCT
Public TODO
End Structure
FO_Func
I tried to use this to send files to the recycle bin. It failed (Marshal.GetLastWin32Error was 6, invalid handle) and sometimes threw a NullReferenceException. To make it work I did the following;
public IntPtr pFrom;
public IntPtr pTo;
In my case I only needed pTo so I just added a null byte to the end and used Marshal.StringToHGlobalUni() to set the value